/**
 * Rule1.java
 * 
 * Copyright (C) 2012 - Thibault BUREL
 * 
 * This file is part of MathDraft.
 *
 * MathDraft is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MathDraft is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MathDraft.  If not, see <http://www.gnu.org/licenses/>
 *  
 */
package drk.mathdraft.rules;

import drk.mathdraft.StudiedProposition;
import drk.mathdraft.proposition.*;
import drk.mathdraft.proposition.builder.NaturalNotation;
import drk.mathdraft.proposition.builder.SyntaxException;


public class Rule1
{
	/*************************************************************************
	 *                          M E T H O D S                                *
	 *************************************************************************/
	/**
	 * Rule1 direct : a = b \Rightarrow a + c = b + c
	 */
	public static void applyDirectRule1(Proposition p, String exp) throws RuleException
	{
		if(p instanceof Equality) 
		{
			Proposition e;
			try
			{
				e = NaturalNotation.fromNaturalNotation (exp);
				((Equality)p).mulSameExpEachMembers(e);
				StudiedProposition.getInstance().forceUpdate();
			}
			catch (SyntaxException exc)
			{
				throw new RuleException("Illegal expression to add !");
			}
		}
		else
		{
			throw new RuleException("Selected node must be equality !");
		}
			
	}
	
	/**
	 * Rule1 inverse :  a + c = b + c \Rightarrow  a = b
	 */	
	public static void applyInverseRule1(Proposition left, Proposition right)
		throws RuleException
	{
		
			
	}
}